<template>
  <div class="app-container">
<!--    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">-->
<!--      <el-form-item>-->
<!--        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>-->
<!--        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>-->
<!--      </el-form-item>-->
<!--    </el-form>-->

<!--    <el-row :gutter="10" class="mb8">-->
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="primary"-->
<!--          plain-->
<!--          icon="el-icon-plus"-->
<!--          size="mini"-->
<!--          @click="handleAdd"-->
<!--          v-hasPermi="['video:RegisterSettings:add']"-->
<!--        >新增</el-button>-->
<!--      </el-col>-->
<!--      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
<!--    </el-row>-->

    <el-table v-loading="loading" :data="RegisterSettingsList" >
      <el-table-column type="selection" width="55" align="center" />
<!--      <el-table-column label="ID" align="center" prop="id" />-->
      <el-table-column label="昵称(是否必填)" align="center" prop="usernameFill" />
      <el-table-column label="昵称(是否显示)" align="center" prop="usernameShow" />
      <el-table-column label="密码(是否必填)" align="center" prop="passwordFill" />
      <el-table-column label="密码(是否显示)" align="center" prop="passwordShow" />
      <el-table-column label="确认密码(是否必填)" align="center" prop="repasswordFill" />
      <el-table-column label="确认密码(是否显示)" align="center" prop="repasswordShow" />
      <el-table-column label="手机号(是否必填)" align="center" prop="mobileFill" />
      <el-table-column label="手机号(是否显示)" align="center" prop="mobileShow" />
      <el-table-column label="验证码(是否必填)" align="center" prop="codeFill" />
      <el-table-column label="验证码(是否显示)" align="center" prop="codeShow" />
      <el-table-column label="真实姓名(是否显示)" align="center" prop="realnameFill" />
      <el-table-column label="真实姓名(是否显示)" align="center" prop="realnameShow" />
      <el-table-column label="性别(是否必填)" align="center" prop="genderFill" />
      <el-table-column label="性别(是否显示)" align="center" prop="genderShow" />
      <el-table-column label="邮箱(是否必填)" align="center" prop="emailFill" />
      <el-table-column label="邮箱(是否显示)" align="center" prop="emailShow" />
      <el-table-column label="邀请码(是否必填)" align="center" prop="invitationcodeFill" />
      <el-table-column label="邀请码(是否显示)" align="center" prop="invitationcodeShow" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['video:RegisterSettings:edit']"
          >修改</el-button>
<!--          <el-button-->
<!--            size="mini"-->
<!--            type="text"-->
<!--            icon="el-icon-delete"-->
<!--            @click="handleDelete(scope.row)"-->
<!--            v-hasPermi="['video:RegisterSettings:remove']"-->
<!--          >删除</el-button>-->
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改APP注册设置对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-form-item label="昵称(是否必填)" prop="usernameFill">
          <el-select v-model="form.usernameFill" placeholder="请选择" >
            <el-option
              v-for="item in dict.type.register_is_fill"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="昵称(是否显示)" prop="usernameShow">
          <el-select v-model="form.usernameShow" placeholder="请选择" >
            <el-option
              v-for="item in dict.type.register_is_fill"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="密码(是否必填)" prop="passwordFill">
          <el-select v-model="form.passwordFill" placeholder="请选择" >
            <el-option
              v-for="item in dict.type.register_is_fill"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="密码(是否显示)" prop="passwordShow">
          <el-select v-model="form.passwordShow" placeholder="请选择" >
            <el-option
              v-for="item in dict.type.register_is_fill"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="确认密码(是否必填)" prop="repasswordFill">
          <el-select v-model="form.repasswordFill" placeholder="请选择" >
            <el-option
              v-for="item in dict.type.register_is_fill"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="确认密码(是否显示)" prop="repasswordShow">
          <el-select v-model="form.repasswordShow" placeholder="请选择" >
            <el-option
              v-for="item in dict.type.register_is_fill"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="手机号(是否必填)" prop="mobileFill">
          <el-select v-model="form.mobileFill" placeholder="请选择" >
            <el-option
              v-for="item in dict.type.register_is_fill"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="手机号(是否显示)" prop="mobileShow">
          <el-select v-model="form.mobileShow" placeholder="请选择" >
            <el-option
              v-for="item in dict.type.register_is_fill"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="验证码(是否必填)" prop="codeFill">
          <el-select v-model="form.codeFill" placeholder="请选择" >
            <el-option
              v-for="item in dict.type.register_is_fill"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="验证码(是否显示)" prop="codeShow">
          <el-select v-model="form.codeShow" placeholder="请选择" >
            <el-option
              v-for="item in dict.type.register_is_fill"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="真实姓名(是否显示)" prop="realnameFill">
          <el-select v-model="form.realnameFill" placeholder="请选择" >
            <el-option
              v-for="item in dict.type.register_is_fill"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="真实姓名(是否显示)" prop="realnameShow">
          <el-select v-model="form.realnameShow" placeholder="请选择" >
            <el-option
              v-for="item in dict.type.register_is_fill"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="性别(是否必填)" prop="genderFill">
          <el-select v-model="form.genderFill" placeholder="请选择" >
            <el-option
              v-for="item in dict.type.register_is_fill"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="性别(是否显示)" prop="genderShow">
          <el-select v-model="form.genderShow" placeholder="请选择" >
            <el-option
              v-for="item in dict.type.register_is_fill"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="邮箱(是否必填)" prop="emailFill">
          <el-select v-model="form.emailFill" placeholder="请选择" >
            <el-option
              v-for="item in dict.type.register_is_fill"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="邮箱(是否显示)" prop="emailShow">
          <el-select v-model="form.emailShow" placeholder="请选择" >
            <el-option
              v-for="item in dict.type.register_is_fill"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="邀请码(是否必填)" prop="invitationcodeFill">
          <el-select v-model="form.invitationcodeFill" placeholder="请选择" >
            <el-option
              v-for="item in dict.type.register_is_fill"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="邀请码(是否显示)" prop="invitationcodeShow">
          <el-select v-model="form.invitationcodeShow" placeholder="请选择" >
            <el-option
              v-for="item in dict.type.register_is_fill"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listRegisterSettings, getRegisterSettings, delRegisterSettings, addRegisterSettings, updateRegisterSettings } from "@/api/video/RegisterSettings";

export default {
  name: "RegisterSettings",
  dicts: ['register_is_fill'],

  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // APP注册设置表格数据
      RegisterSettingsList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        usernameFill: null,
        usernameShow: null,
        passwordFill: null,
        passwordShow: null,
        repasswordFill: null,
        repasswordShow: null,
        mobileFill: null,
        mobileShow: null,
        codeFill: null,
        codeShow: null,
        realnameFill: null,
        realnameShow: null,
        genderFill: null,
        genderShow: null,
        emailFill: null,
        emailShow: null,
        invitationcodeFill: null,
        invitationcodeShow: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询APP注册设置列表 */
    getList() {
      this.loading = true;
      listRegisterSettings(this.queryParams).then(response => {
        this.RegisterSettingsList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        usernameFill: null,
        usernameShow: null,
        passwordFill: null,
        passwordShow: null,
        repasswordFill: null,
        repasswordShow: null,
        mobileFill: null,
        mobileShow: null,
        codeFill: null,
        codeShow: null,
        realnameFill: null,
        realnameShow: null,
        genderFill: null,
        genderShow: null,
        emailFill: null,
        emailShow: null,
        invitationcodeFill: null,
        invitationcodeShow: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加APP注册设置";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getRegisterSettings(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改APP注册设置";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateRegisterSettings(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addRegisterSettings(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除APP注册设置编号为"' + ids + '"的数据项？').then(function() {
        return delRegisterSettings(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('video/RegisterSettings/export', {
        ...this.queryParams
      }, `RegisterSettings_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
